package com.exp.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

/**
 *
 * @author zhangxj
 * @date 2025/1/2
 * @Description
 */
@Configuration
public class WebSecurityConfig {
    @Bean
    public UserDetailsService userDetailsService() {
        // 创建基于内存的用户信息管理器
        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
        // 使用 manager 管理用户对象
        manager.createUser(
                // UserDetails 对象，包含用户名、密码、角色等信息
                User.withDefaultPasswordEncoder().username("jin").password("password").roles("USER").build()
        );
        return manager;
    }
}
